<template>
  <div class="home">
    <!-- <img alt="Vue logo" src="../assets/logo.png" />
    <HelloWorld msg="Welcome to Your Vue.js App" /> -->
    我是2-2-
  </div>
</template>

<script>
// @ is an alias to /src
// import HelloWorld from "@/components/HelloWorld.vue";
import axios from "axios";
// import { delete } from "vue/types/umd";
export default {
  name: "Home",
  // components: {
  //   HelloWorld,
  // },
  created() {
    axios.get("/data.json").then((res) => {
      console.log(res);
    });
    // post
    // form-data 表单提交 （图片上传，文件上传）
    // application/json 请求
    let data = {
      id: 12,
    };
    axios.post("/post", data).then((res) => {
      console.log("data", res);
    });
    axios({
      method: "post",
      url: "/post",
      data: data,
    }).then((res) => {
      console.log("application", res);
    });
    // form-data 请求
    let formData = new FormData();

    for (let key in data) {
      formData.append(key, data[key]);
    }
    axios.post("./post", formData).then((res) => {
      console.log("formData", res);
    });
    // put 请求
    axios.put("/put", data).then((res) => {
      console.log(res);
    });
    // patch 请求
    axios.patch("/patch", data).the((res) => {
      console.log(res);
    });
    // axios
    //   .delete("/delete", {
    //     data: {
    //       id: 12,
    //     },
    //   })
    //   .the((res) => {
    //     console.log(res);
    //   });
    // delete 请求
    axios
      .delete("/delet", {
        params: {
          id: 12,
        },
      })
      .tehn((res) => {
        console.log(res);
      });

    axios
      .delete("/delete", {
        params: {
          id: 12,
        },
      })
      .then((res) => {
        console.log(res);
      });
    axios
      .delete("/delete", {
        data: {
          id: 12,
        },
      })
      .then((res) => {
        console.log(res);
      });
    // 路径传参
    axios({
      method: "delete",
      url: "/delete",
      parmams: {
        id: 12,
      },
    });
    axios({
      method: "delete",
      url: "/delete",
      data: {
        id: 12,
      },
    });
  },
};
</script>
